<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/const/Pattern.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/const/Error.php';
?>
<SCRIPT type="text/javascript" src="/view/javascripts/form.js"></SCRIPT>
<?php
if($response->isParameter('post')) {
	$post = $response->getParameter('post');
	$name = $post->getName();
	$unique = $post->isUnique();
} else {
	$name = '';
	$unique = false;
}
?>
<DIV class="block">
<?php
if($response->isParameter('post')) {
?>
	<H1><A href="/post/index.html">Должности</A> :: должность «<?php echo $name;?>»</H1>
<?php
} else {
?>
	<H1><A href="/post/index.html">Должности</A> :: новая должность</H1>
<?php
}
?>
	<FORM action="/post/update.html" method="post" id="edit">
<?php
if($response->isParameter('post')) {
?>
		<INPUT type="hidden" name="identity" value="<?php echo $post->getIdentity();?>">
<?php
}
?>
		<TABLE>
			<TR>
				<TD><LABEL for="name">название:</LABEL></TD>
				<TD>
					<INPUT type="text" id="name" name="name"
							value="<?php echo $name;?>"
							pattern="<?php echo Pattern::WORDS;?>"
							message="<?php echo Error::INCORRECT_POST_NAME;?>"
							maxlength="50">
				</TD>
			</TR>
			<TR>
				<TD title="уникальную должность может занимать только один сотрудник">
					<LABEL for="unique">уникальность:</LABEL>
				</TD>
				<TD>
<?php
if($unique) {
?>
					<INPUT type="checkbox" id="unique" name="unique"
							value="unique" checked="checked">
<?php
} else {
?>
					<INPUT type="checkbox" id="unique" name="unique"
							value="unique">
<?php
}
?>
				</TD>
			</TR>
		</TABLE>
	</FORM>
</DIV>
<DIV class="block">
	<BUTTON type="button" onclick="submitForm('edit')">
		<IMG src="/view/img/button-save.png" alt="">
		<SPAN>сохранить</SPAN>
	</BUTTON>
	<BUTTON type="button" onclick="resetForm('edit')">
		<IMG src="/view/img/button-reset.png" alt="">
		<SPAN>сбросить</SPAN>
	</BUTTON>
<?php
if($response->isParameter('post')) {
?>
	<FORM action="/post/delete.html" method="post" class="inline">
		<INPUT type="hidden" name="identity" value="<?php echo $post->getIdentity();?>">
		<BUTTON type="submit">
			<IMG src="/view/img/button-delete.png" alt="">
			<SPAN>удалить</SPAN>
		</BUTTON>
	</FORM>
<?php
}
?>
	<FORM action="/post/index.html" method="get" class="inline">
		<BUTTON type="submit">
			<IMG src="/view/img/button-back.png" alt="">
			<SPAN>назад</SPAN>
		</BUTTON>
	</FORM>
</DIV>